Imports System.ComponentModel
Imports Aricie.DNN.UI.Attributes
Imports Aricie.ComponentModel
Imports DotNetNuke.UI.WebControls
Imports System.Xml.Serialization
Imports Aricie.DNN.UI.WebControls.EditControls

Namespace Aricie.DNN.Caching
    <DefaultProperty("Name")> _
    <Serializable()> _
    Public Class CacheGroupInfo
        Inherits CacheStrategy

        Public Sub New()

        End Sub

        Public Sub New(ByVal name As String, ByVal objStrategy As CacheStrategy)
            MyBase.New(objStrategy.Enabled, objStrategy.KeyFormat, objStrategy.DistributionType, objStrategy.SkipCatalogCheck, objStrategy.ConcurrencyMode, objStrategy.CompressionThresold, objStrategy.ClusterName, objStrategy.RegionName, objStrategy.EvictionsOn, _
                       objStrategy.BatchMode, objStrategy.PutTags, objStrategy.GetTags, objStrategy.TimeOutMode, objStrategy.TimeOutConstant, _
                       objStrategy.DisableSlidingEmulation, objStrategy.DisableSynchronization, objStrategy.AddGlobalDependency, objStrategy.DisableClusterRemoval, _
                       objStrategy.DisableReflectedCallBacks, objStrategy.NoLocalInsertOnDistributedCachingGet, objStrategy.LogOperations)
            Me._Name = name
        End Sub


        Private _Name As String = ""
        'Private _Strategy As New CacheKeyInfo

        Private _Keys As New List(Of String)
        Private _VariableKeys As New List(Of RegexMapping)


        <Category("")> _
        <MainCategory()> _
        Public Property Name() As String
            Get
                Return _Name
            End Get
            Set(ByVal value As String)
                _Name = value
            End Set
        End Property


        <Category("GroupSettings")> _
    <Editor(GetType(ListEditControl), GetType(EditControl))> _
    <CollectionEditor(False, False, True, True, 15)> _
    <LabelMode(LabelMode.Top)> _
        Public Property VariableKeys() As List(Of RegexMapping)
            Get
                Return _VariableKeys
            End Get
            Set(ByVal value As List(Of RegexMapping))
                _VariableKeys = value
            End Set
        End Property

        <Category("GroupSettings")> _
        <XmlIgnore()> _
        <Editor(GetType(CustomTextEditControl), GetType(EditControl))> _
        <LineCount(15), Width(800), LabelMode(LabelMode.Top)> _
        Public Property StringKeys() As String
            Get
                Return CacheStrategy.FormatKeys(Me._Keys.ToArray)
            End Get
            Set(ByVal value As String)
                Me._Keys = New List(Of String)(value.Trim.Trim(","c).Split(glbKeysSeparator, StringSplitOptions.RemoveEmptyEntries))
                Me._Keys.Sort()
            End Set
        End Property








        <Browsable(False)> _
        Public Property Keys() As List(Of String)
            Get
                Return _Keys
            End Get
            Set(ByVal value As List(Of String))
                _Keys = value
            End Set
        End Property

        Public Overrides Function Equals(ByVal obj As Object) As Boolean
            Dim group As CacheGroupInfo = CType(obj, CacheGroupInfo)

            Return Me.Name.Equals(group.Name)
        End Function


    End Class
End Namespace